import { handleActions } from 'redux-actions'
import { INCREMENT, DECREMENT, ADD_ORDER, REMOVE_ORDER } from '../types/counter'

const defaultState = {
  num: 0,
  order: null
}
export default handleActions({
  [INCREMENT] (state) {
    return {
      ...state,
      num: state.num + 1
    }
  },
  [DECREMENT] (state) {
    return {
      ...state,
      num: state.num - 1
    }
  },
  [ADD_ORDER] (state, action) {
    console.log('=======action',action)
    return {
      ...state,
      order: action.payload
    }
  },
  [REMOVE_ORDER] (state, action) {
    return {
      ...state,
      order: null
    }
  }
}, defaultState)
